<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <include file="Common:header_include"/>
    <title>首页</title>
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
            <a class="navbar-brand" href="#">欢迎来到易术网！</a>
        </div>
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav navbar-right">
                <li><a href="{:U('Logout')}">退出</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <li class="dropdown"><img src="__HIMG__photo.png" alt="" style="width: 25px;margin-top: 11px"/></li>
                <li class="dropdown"><a href="{:U('Doctor/info')}">个人中心</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <li class="NEW"><a class="headerBox" href="javascript:;">消息<b>3</b></a>
                    <div class="show_text">
                        <a href="" class="list">sdfsdf</a>
                        <a href="" class="list">sdfsdf</a>
                        <a href="" class="list">sdfsdf</a>
                        <a href="" class="list">sdfsdf</a>
                        <a href="" class="list">sdfsdf</a>

                    </div>
                </li>
                <!--可添加消息-->
            </ul>
        </div>
    </div>
</nav>
<!--LOGO-->
<div class="header_cont">
    <a href="javascript:;">
        <span class="logo"></span><img src="__HIMG__text.png" alt=""/>
    </a>
</div>
<!--面包屑导航-->
<ol class="breadcrumb ">
    <li><span class="glyphicon glyphicon-home"></span> <a href="{:U('Index/index')}">首页</a></li>
    <li class="active">我的病人</li>
    <!--<li><a href="#">“张三”健康档案</a></li>-->
    <!--<li class="active">Data</li>-->
</ol>
<!--主体开始-->
<div class="container">
    <?php
                if($_GET['state']==""){
                  $_GET['state']=1;
                }
                ?>
    <ul class="nav nav-tabs" role="tablist" id="myTab" style="border-bottom: 1px solid #DDDDDD">
        <volist name="status" id="k">
            <li role="presentation" <if condition="$k['id'] eq $_GET['state'] "> class="active"</if> >
            <a href="?state={$k['id']}" >{$k.title}</a>
            </li>
        </volist>
    </ul>
    <div class="tab-content">
        <div role="tabpanel" class="tab-pane active" id="one">
            <table class="table table-hover " >
                <volist name=":patientStatusList($_GET['state'])" id="v">
                    <tr>
                        <td class="img">
                            <a href="{:U('HealthRecord/info',array('id'=>$v[patient]['id'],'status_id'=>$v['status_id']))}">
                                <if condition="$v[patient]['cover']">
                                    <img src="__UPS__{$v[patient]['cover']}" class="cover"/>
                                    <else/>
                                    <img src="__HIMG__photo.png" class="cover"/>
                                </if>
                            </a>
                        </td>
                        <td class="name" title="{$v['remark']}">
                            <p>

                                <span>
                                    姓名：{$v[patient]['true_name']}
                                </span>

                                 <span> 性别：
                                    <if condition="$v[patient]['gender'] eq 0"> 女</if>
                                    <if condition="$v[patient]['gender'] eq 1"> 男</if>
                                 </span>
                                <span>
                                    年龄:{$v[patient]['age']}
                                </span>
                            </p>
                            <p style="color: red">
                                <if condition="empty($v[helper]['true_name'])">
                                    未分配助手
                                    <else/>
                                    已分配给助手：{$v[helper]['true_name']}
                                </if>
                            </p>
                            <p>
                               备注：{$v['remark']}
                            </p>
                        </td>
                        <?php
                        if(empty($v[helper]['id'])){
                          $v[helper]['id'] = 0;
                        }
                       ?>
                        <td class="btn_box">
                            <a   onclick="Byval({$v[patient]['id']},{$v[helper]['id']})"  class="btn btn-warning" data-toggle="modal" data-target=".myModal" >分配</a>
                            <if condition="$_GET['state'] eq 1">
                                <a   href="{:U('editstatus',array('patient_id'=>$v[patient]['id'],'type'=>1))}"  class="btn btn-success">同意</a>
                                <a   href="{:U('editstatus',array('patient_id'=>$v[patient]['id'],'type'=>0))}"   class="btn btn-info">拒绝</a>
                                <elseif condition="$_GET['state']  eq 2"/>
                                <button type="button" class="btn btn-success">交流</button>
                                <button type="button" class="btn btn-info" onclick="javascript:top.location='shoushuzhuizong.html';" value="_black">手术追踪</button>
                                <button type="button" class="btn btn-danger">诊断</button>
                                <elseif condition="$_GET['state']  eq 4"/>
                                <button type="button" class="btn btn-success">交流</button>
                                <button type="button" class="btn btn-info" onclick="javascript:top.location='shoushuzhuizong.html';" value="_black">手术追踪</button>
                                <button type="button" class="btn btn-danger">约谈</button>
                                <elseif condition="$_GET['state']  eq 5"/>
                                <button type="button" class="btn btn-success">交流</button>
                                <button type="button" class="btn btn-info" onclick="javascript:top.location='shoushuzhuizong.html';" value="_black">手术追踪</button>
                                <button type="button" class="btn btn-danger">术前</button>
                                <elseif condition="$_GET['state']  eq 6"/>
                                <button type="button" class="btn btn-success">交流</button>
                                <button type="button" class="btn btn-info" onclick="javascript:top.location='shoushuzhuizong.html';" value="_black">手术追踪</button>
                                <button type="button" class="btn btn-danger">术后</button>
                                <elseif condition="$_GET['state']  eq 7"/>
                                <button type="button" class="btn btn-success">交流</button>
                                <button type="button" class="btn btn-info" onclick="javascript:top.location='shoushuzhuizong.html';" value="_black">手术追踪</button>
                                <button type="button" class="btn btn-danger">出院</button>
                                <else/>
                                <button type="button" class="btn btn-success">交流</button>
                                <button type="button" class="btn btn-info" onclick="javascript:top.location='shoushuzhuizong.html';" value="_black">术后随访</button>
                            </if>
                        </td>
                    </tr>

                </volist>
            </table>
        </div>

    </div>
    <div class="modal fade myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title text-left" id="myModalLabel">权限分配</h4>
                </div>
                <div class="modal-body">
                    <!--搜索助手开始-->
                    <!--搜索助手结束-->
                    <div class="clear">
                        <table class="table table-hover table-bordered text-center helper-list" id="text_helper">
                            <thead>
                            <tr style="background: #f8f8f8" class=" helper-name" id="helpername">
                                <th><b>姓名</b></th>
                                <th><b>科室</b></th>
                                <th><b>主治疾病</b></th>
                                <th><b>联系方式</b></th>
                                <th><b>操作</b></th>
                            </tr>
                            </thead>
                                <volist name=":GethelperList()" id="k">
                                    <tr class="text-center" style="vertical-align:middle">
                                        <input  type="text" value="" style="display: none" id="patient_id">
                                        <input  type="text" value="" style="display: none" id="helper_id">
                                        <td >{$k['true_name']}</td>
                                        <td >{$k[department]['title']}</td>
                                        <td >{:ArrayTo($k['disease_id'])}</td>
                                        <td>{$k['phone']}</td>
                                        <td>
                                            <a id="alloc{$k['id']}" data-toggle="modal" onclick="allocation({$k['id']})" class="btn-success btn-xs">
                                                分配
                                            </a>
                                        </td>
                                    </tr>
                              </volist>
                        </table>
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
<!--主体结束-->
<include file="Common:footer_include"/>
<script>
    var selId="";
    function Byval(id,helper_id) {
        $('#patient_id').val(id);
        $('#alloc'+selId).html('分配');
        $('#alloc'+helper_id).html('已分配');
        $('#alloc'+helper_id).attr('onclick',null);
        selId = helper_id;
    }

    function allocation(helper_id) {
        //ajax提交分配助手
        var ajaxurl = "{:U('Index/allocation')}";
        var query = new Object();
        query.patient_id = $("#patient_id").val();
        query.helper_id = helper_id;
        $.ajax({
            url:ajaxurl,
            data:query,
            type:"Post",
            dataType:"json",
            success:function(data){
                if(data.status==1){
                    alert(data['info']);
                    window.location.href = "{:U('Index/index')}";
                } else {
                    alert(data['info']);
                }
            }
        });
    }
    tableSort($('#text_helper'));
    function tableSort(obj) {

        var actionColumnIndex = $('#helpername th').length;
        if (!actionColumnIndex || actionColumnIndex < 1) {
            return;
        }

        obj.dataTable({
            "aaSorting": [[1, "desc"]],
            "bStateSave": false,
            "aoColumnDefs": [
                {
                    "orderable": false, "aTargets": [0, actionColumnIndex - 1]
                }
            ],
            "aLengthMenu": [[6], [6]],
            "sPaginationType": "full_numbers",
            "sDom": '<"top"f>rt<"bottom">p<"clear">'
//            "sDom": '<"top"fli>rt<"bottom">p<"clear">'

        });

    }

</script>
</body>
</html>